//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Reader.Components;

namespace CommunityServer.Reader.Controls
{
	/// <summary>
	/// Summary description for FolderListing.
	/// </summary>
	public class RollerPostListing : RollerTemplatedWebControl
	{

		#region Private Members

		private Repeater rPosts;
        private IPagedControl pager;
		private int PageSize;

		#endregion

		#region Constructor(s)

		public RollerPostListing()
		{
		}

		#endregion

		#region Class Methods

		protected override void AttachChildControls()
		{
			rPosts = (Repeater) FindControl("rPosts");
            pager = FindControl("Pager") as IPagedControl;
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);
			
				DataBind();
    
		    UsersOnline.SetLocation("Syndicator");

		}


		public override void DataBind()
		{
			base.DataBind ();

			int userId = Users.GetAnonymousUser().UserID;

			ReaderConfiguration config = ReaderConfiguration.Instance();
			PageSize				   = config.PageSize;

            int pageIndex = CSContext.Current.PageIndex;
            FeedPostSet posts = FeedPosts.GetRollerPosts(pageIndex,PageSize);

            if(pager != null)
            {
                pager.PageIndex = pageIndex;
                pager.PageSize = PageSize;
                pager.TotalRecords = posts.TotalRecords;
            }

			rPosts.DataSource = posts;
			rPosts.DataBind();
		}

		#endregion

	}
}
